import Vue from 'vue'
import router from './router'
import axios from 'axios'
import VueAxios from 'vue-axios'
import VueLazyLoad from 'vue-lazyload'
import VueCookie from 'vue-cookie'
import {Message, Button, Input, Form, FormItem} from 'element-ui'

import App from './App.vue'
import 'element-ui/lib/theme-chalk/index.css'

axios.defaults.baseURL = '/api/sysInterface'
axios.defaults.timeout = 8000
axios.interceptors.request.use(config => {
  /* eslint-disable */
  console.log(config)
  config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
  return config
})
axios.interceptors.response.use(res => {
  // const {data} = res
  if(res.status === 200){
    return res
  }else{
    Message.warning(msg.msg)
    return Promise.reject(res)
  }
}, (err) => {
  let res = err.response
  Message.error(res.data.message)
  return Promise.reject(err)
})

Vue.config.productionTip = false
Vue.use(VueAxios, axios)
Vue.use(VueCookie)
Vue.use(VueLazyLoad, {
  loading: '/images/loading-svg/loading-bars.svg'
})
Vue.use(Button)
Vue.use(Input)
Vue.use(Form)
Vue.use(FormItem)
Vue.prototype.$message = Message

new Vue({
  router,
  render: h => h(App),
}).$mount('#app')
